<template>
  <f7-page>
      <f7-navbar back-link="返回" title="发布司机运输"></f7-navbar>
      <f7-button @click="delogSetPrductType()" v-if="productType.length==0">
        设置产品分类
      </f7-button>
    <div @click="delogSetPrductType()">
      <template v-for="item in productType" >
        {{item}}
      </template>
    </div>


    <hr/>

      <f7-button @click="delogSetProductCategory()" v-if="productCateParam.attribute">
          添加产品
      </f7-button>

      <div v-for="item in productCate">
        <div>{{item.name}}</div>
        <div v-for="attr in  item.proAttr.attribute">
          {{attr.name}}:{{attr.value}}
        </div>
      </div>


      <div @click="goAdds('th')">提货地址:{{addsStr.th}}</div>
      <div @click="goAdds('sh')">收货地址:{{addsStr.sh}}</div>

    运费：<input type="text" />
    信息费：<input type="text" />
    司机接单截止时间  <myDatepicker @dtpkChange="driverDeadline"></myDatepicker>




    <setProductType ref="setPrductType" @setProductTypeDone="setProductTypeDoneEmit"></setProductType>
    <setProductCategory ref="setPrductCategory" @setProductCateDoneEmit="setProductCateDoneEmit" :data="productCateParam"></setProductCategory>
  </f7-page>
</template>

<script>

import setProductType  from '../../components/setProductType.vue'
import setProductCategory  from '../../components/setProductCategory.vue'
import F7Button from "framework7-vue/src/components/button";
import myDatepicker from '../../components/datetimepicker'
export default {
  name: 'creatDriverDemand',
  data () {
    return {
        productType:[],
        productCate:{},
        productCateParam:{},
        addsType:'',
        addsStr:{
            th:'',
            sh:''
        },
    }
  },
  components: {
      F7Button,
      setProductType,
      setProductCategory,
      myDatepicker
  },
  methods: {
      delogSetPrductType(){
          this.$refs.setPrductType.openPop()
      },
      delogSetProductCategory(){
          this.$refs.setPrductCategory.openPop()
      },
      setProductTypeDoneEmit(data){
          this.$refs.setPrductCategory.clearDate()
          this.productCate=[];
          this.productType=data.productType;
          this.productCateParam=data.productCate;
      },
      setProductCateDoneEmit(data){
          this.productCate=[];
          this.productCate=data.productCate;
      },
      goAdds(type){
          this.addsType=type;
          this.$f7.router.navigate('/mine/address/:source?')
      },
      driverDeadline(data){

      }
  },
  watch: {
      '$store.state.adds'(val) {
          if(val==''){return;}
          let addStr=`${val.province} ${val.city} ${val.district}`
          this.addsStr[this.addsType]=addStr
      }
  }
}
</script>

<style scoped>

</style>
